﻿package mortal.game.view.rebate.openNewSerSevenDay
{
    import Message.Public.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.rebate.openNewSerSevenDay.items.*;
    import mortal.game.view.rebate.openNewSerSevenDay.panels.*;
    import mortal.game.view.rebate.openServerSevenDay.data.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class OpenNewSerSevenDayModule extends BaseWindow
    {
        protected var _bg:ScaleBitmap;
        protected var _bg2:ScaleBitmap;
        protected var _tabBar:GTileList;
        protected var _panel:OpenNewSerSevInfoPanel;
        private var _info:Object;

        public function OpenNewSerSevenDayModule(param1:ILayer = null)
        {
            super(param1);
            setSize(900, 600);
            title = "" + Language.getString(71828);
            this.layer = LayerManager.windowLayer3D;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg2 = UIFactory.bg(202, 36, 694, 563, this, ImagesConst.PanelBg);
            this._bg = UIFactory.bg(6, 35, 197, 565, this, ImagesConst.PanelBg);
            this._tabBar = UIFactory.tileList(10, 41, 203, 540, this);
            this._tabBar.direction = GBoxDirection.VERTICAL;
            this._tabBar.verticalGap = 0;
            this._tabBar.horizontalGap = 2;
            this._tabBar.rowHeight = 60;
            this._tabBar.columnWidth = 188;
            this._tabBar.columnCount = 1;
            this._tabBar.rowCount = 9;
            this._tabBar.width = 203;
            this._tabBar.setStyle("cellRenderer", OpenNewSerSevCellRender);
            this._tabBar.configEventListener(Event.CHANGE, this.tabBarChangeHandler);
            this._panel = UIFactory.getUICompoment(OpenNewSerSevInfoPanel, 205, 43, this, this);
            this.initTabs();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._panel.dispose(param1);
            this._panel = null;
            this._bg = null;
            this._tabBar = null;
            this._bg2 = null;
            if (OpenNewSerSevRight.isViewShow())
            {
                OpenNewSerSevRight.instance.hide();
            }
            super.disposeImpl(param1);
            return;
        }// end function

        public function initTabs() : void
        {
            var _loc_1:* = OpenServerSevenDayUtil.getSevenDayTabData();
            Cache.instance.openServerSevenDay.sevenDayTabArr = _loc_1[0];
            Cache.instance.openServerSevenDay.sevenDayRangeTabArr = _loc_1[1];
            this.setData(_loc_1[0]);
            this._tabBar.selectedIndex = this._tabBar.dataProvider.length < 2 ? (0) : (2);
            this.tabBarChangeHandler(null);
            return;
        }// end function

        public function setData(param1:Array) : void
        {
            if (param1 == null)
            {
                return;
            }
            this._tabBar.dataProvider = new DataProvider(param1);
            return;
        }// end function

        private function tabBarChangeHandler(event:Event = null) : void
        {
            var _loc_2:* = this._tabBar.selectedIndex;
            this._info = this._tabBar.dataProvider.getItemAt(_loc_2);
            this._panel.updateInfo(this._info, _loc_2);
            Dispatcher.dispatchEvent(new DataEvent(EventName.RebateOpenServerSevenDayReq, _loc_2));
            return;
        }// end function

        public function setRangeData(param1:Array, param2:int) : void
        {
            if (param1 == null || param1.length == 0 || param1[0] == null || param1[0] == "")
            {
                this._panel.initCell0(this._info ? (this._info.dayNum) : (1));
                return;
            }
            var _loc_3:* = param1[0] as SToplist;
            this._panel.updateRole(_loc_3, this._info ? (this._info.dayNum) : (1));
            return;
        }// end function

        public function updateCanGet() : void
        {
            if (this._panel)
            {
                this._panel.updateGetBtn();
            }
            return;
        }// end function

        override protected function onMouseMoveHandler(event:MouseEvent) : void
        {
            super.onMouseMoveHandler(event);
            if (OpenNewSerSevRight.isViewShow())
            {
                OpenNewSerSevRight.instance.x = this.x + this.width + 5;
                OpenNewSerSevRight.instance.y = this.y;
            }
            return;
        }// end function

        override public function stageResize() : void
        {
            super.stageResize();
            if (OpenNewSerSevRight.isViewShow())
            {
                LayerManager.windowLayer.centerWindows(this, OpenNewSerSevRight.instance);
            }
            return;
        }// end function

        override protected function onWindowDownHandler(event:MouseEvent) : void
        {
            super.onWindowDownHandler(event);
            if (OpenNewSerSevRight.isViewShow())
            {
                OpenNewSerSevRight.instance.layer.setTop(OpenNewSerSevRight.instance);
            }
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            if (OpenServerSevenDayUtil.isNotOpenSpeActive())
            {
                return;
            }
            super.show();
            OpenNewSerSevRight.instance.show();
            LayerManager.windowLayer.centerWindows(this, OpenNewSerSevRight.instance);
            return;
        }// end function

    }
}
